import java.util.Arrays;

class Solution {
    public int lengthOfLIS(int[] nums) {
        // 创建 dp 表、初始化、填表、返回值
        int n = nums.length;
        int[] dp = new int[n];

        // 将数组全部初始化为最小值1
        Arrays.fill(dp, 1);

        for (int i = 1; i < n; i++) {
            for (int j = i-1; j >= 0; j--) {
                if (nums[j] < nums[i]) {
                    dp[i] = Math.max(dp[i], dp[j]+1);
                }
            }
        }

        int ret = 0;
        for (int i = 0; i < n; i++) {
            ret = Math.max(ret, dp[i]);
        }

        return ret;
    }
}